The Impact of Internal Migration in Redistributing Population: Population Concentration, Deconcentration or Spatial Equilibrium

load libraries

## Linking to GEOS 3.6.1, GDAL 2.1.3, PROJ 4.9.3
## [1] "/Users/Franciscorowe/Dropbox/Francisco/Research/website/franciscorowe.github.io/content/post"

read files

## Reading layer `eu_netmigration' from data source `/Users/Franciscorowe/Dropbox/Francisco/Research/website/franciscorowe.github.io/content/post/eu_netmigration.shp' using driver `ESRI Shapefile'
## Simple feature collection with 5006 features and 3 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -180 ymin: -21.38885 xmax: 180 ymax: 81.85732
## epsg (SRID):    4326
## proj4string:    +proj=longlat +datum=WGS84 +no_defs

Categorise data so to specify colours and labels for the map

library(leaflet)

# Specify the colour palette
pal <- colorFactor(palette = c("red", "salmon1", "white", "steelblue1", "blue"), 
           levels = c("less than -2", "-2 to 0", "0", "0 to 2", "more than 2"), ordered = FALSE)

# pal <- colorBin("RdYlBu", domain = spdf$z_score, bins = bins)

# There is a list of all the available background tiles in
# http://leaflet-extras.github.io/leaflet-providers/preview/index.html
# Create the initial background map, zooming in Europe
colourmap <- leaflet() %>% 
  addTiles() %>% 
  setView(lat = 48, lng = 20, zoom = 4) %>% 
  addProviderTiles(providers$NASAGIBS.ViirsEarthAtNight2012, group = "NASAGIBS.ViirsEarthAtNight2012") %>% 
  addProviderTiles(providers$Stamen.TonerLite, group = "Stamen.TonerLite")

# Create the interactive map showing the sequence clusters
interactive_map <- colourmap %>%
  addPolygons(data = combined_data_simpl,
              fillColor = ~pal(z_cat),
              weight = 0.4,
              opacity = 0.8,
              color = "black",
              dashArray = "3",
              fillOpacity = 0.7,
              popup = paste("Name: ", combined_data_simpl$name, "<br>",
                            "Net Migration: ", combined_data_simpl$net_migr, "<br>"),
              group = "Net migration in Europe",
              highlight = highlightOptions(
                weight = 5,
                color = "#666",
                dashArray = "",
                fillOpacity = 0.7,
                bringToFront = TRUE)) %>% 
  addLegend(pal = pal,
            values  = combined_data_simpl$z_cat,
            na.label = "Missing data",
            position = "bottomleft",
            title = "Net migration in Europe (z-scores)") %>% 
  addLayersControl(baseGroups = c("NASAGIBS.ViirsEarthAtNight2012", "Stamen.TonerLite"),
    overlayGroups = "Net migration in Europe",
    options = layersControlOptions(collapsed = FALSE))


interactive_map

If we want to save only the map